#ifndef __VEC_H__
#define __VEC_H__

#include <math.h>

class Vec {
public:
  float x;
  float y;
  Vec(float xx, float yy) {
    x = xx;
    y = yy;
  }
  Vec to(Vec other) {
    return Vec(other.x - x, other.y - y);
  }
  Vec plus(Vec other) {
    return Vec(other.x + x, other.y + y);
  }
  float sq_mag() {
    return pow(x, 2) + pow(y, 2);
  }
  float dot(Vec other) {
    return x*other.x + y*other.y;
  }
  float mag() {
    return sqrt(sq_mag());
  }
  Vec scale(float scale) {
    return Vec(x * scale, y * scale);
  }
  Vec project(Vec other) {
    float proportion = dot(other) / other.sq_mag();
    return other.scale(proportion).scale(50);
  }
  Vec reflect(Vec other) {
    Vec parallel = scale(-1).project(other);
    Vec perpendicular = scale(-1).to(parallel);
    return scale(-1).plus(perpendicular.scale(2));
  }
  Vec unit() {
    return scale(1 / mag());
  }
  int angle() {
    return (int)degreesToAngle(atan2(y, x) * 180/ 3.14159);
  }
};

#endif
